package de.slothsoft.wasbinich.swingclient;

import java.awt.Component;
import java.awt.Dimension;

import javax.swing.SwingUtilities;

import de.slothsoft.commons.swing.AbstractMainFrame;
import de.slothsoft.wasbinich.core.WasBinIch;
import de.slothsoft.wasbinich.core.WasBinIch.Version;
import de.slothsoft.wasbinich.core.database.Database;
import de.slothsoft.wasbinich.swingclient.control.MainPanel;
import de.slothsoft.wasbinich.swingclient.database.SwingWebserviceDatabase;
import de.slothsoft.wasbinich.swingclient.res.Images;

public final class WasBinIchFrame extends AbstractMainFrame {

    private static final long serialVersionUID = 8449989046572719997L;

    public static void main(String[] args) {
	WasBinIch.initVersion(Version.DESKTOP);
	Database.initInstance(new SwingWebserviceDatabase());

	SwingUtilities.invokeLater(new Runnable() {
	    @Override
	    public void run() {
		WasBinIchFrame mainFrame = new WasBinIchFrame();
		mainFrame.open();
	    }
	});
    }

    @Override
    protected Component createComponents() {
	setTitle(WasBinIch.APPLICATION_NAME + " " + WasBinIchSwingClient.APPLICATION_VERSION);
	setIconImage(Images.get(Images.APPLICATION_ICON).getImage());
	WasBinIchSwingClient.setMainPanel(new MainPanel());
	return WasBinIchSwingClient.getMainPanel();
    }

    @Override
    public Dimension getInitialSize() {
	return new Dimension(500, 400);
    }
}
